﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cfg.Attributes;
using Cfg.ConfigValues;
using Cfg.ValidationAttributes;
using NUnit.Framework;

namespace Cfg.Test.IAppConfigTests
{
    public class InheritanceTest
    {
        public interface IBaseCfg
        {
            string StringValue { get; }
        }

        public interface ICfg : IBaseCfg
        {
            int IntValue { get; }
        }

        [Test]
        public void Test()
        {
            var cfg = Cfg.AppSettings.Get<ICfg>();

            Console.WriteLine(cfg.StringValue);
        }
    }


    [TestFixture]
    public class IAppConfigTest
    {
        public interface ICfg
        {
            [MaxLength(20)]
            string StringValue { get; }

            ICfgPathsSection Paths { get; }

            ICfgPathsSection Paths2 { get; }
        }

        public interface ICfgPathsSection
        {
            string SomePath { get; }

            [Path()]
            PathInfo SomeOtherPath { get; }
        }

        [Test]
        public void Get()
        {
            var cfg = AppSettings.Get<ICfg>();

            Console.WriteLine(cfg.StringValue);
            Assert.AreEqual("test", cfg.StringValue);

            Console.WriteLine(cfg.Paths.SomePath);
            Console.WriteLine(cfg.Paths.SomeOtherPath.FullPath);
            Console.WriteLine(cfg.Paths.SomeOtherPath.RelativePath);
            Console.WriteLine(cfg.Paths.SomeOtherPath.Url);

            Console.WriteLine(cfg.Paths2.SomePath);
            Console.WriteLine(cfg.Paths2.SomeOtherPath.FullPath);
            Console.WriteLine(cfg.Paths2.SomeOtherPath.RelativePath);
            Console.WriteLine(cfg.Paths2.SomeOtherPath.Url);
        }
    }
}